package hbase.template;

import org.apache.hadoop.hbase.client.AsyncTable;
import org.apache.hadoop.hbase.client.Mutation;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.client.ScanResultConsumerBase;

import java.util.List;
import java.util.concurrent.CompletableFuture;

public interface HBaseAsyncOperations {

    <T> CompletableFuture<T> execute(String tableName, AsyncTableCallback<CompletableFuture<T>> callback);

    AsyncTable<? extends ScanResultConsumerBase> getTable(String tableName);

    <T> CompletableFuture<List<T>> find(String tableName, Scan scan, RowMapper<T> mapper);

    <T> CompletableFuture<T> get(String tableName, byte[] rowKey, RowMapper<T> mapper);

    <T> CompletableFuture<T> get(String tableName, byte[] rowKey, String familyName, RowMapper<T> mapper);

    <T> CompletableFuture<Void> put(String tableName, T record, RowSerializer<T> serializer);

    <T> void batchInsert(String tableName, List<T> records, RowSerializer<T> serializer);

    long rowCount(String tableName, Scan scan);

    CompletableFuture<Void> delete(String tableName, byte[] rowKey);

    CompletableFuture<Void> delete(String tableName, byte[] rowkey, String familyName);

    CompletableFuture<Void> delete(String tableName, byte[] rowkey, String familyName, String qualifier);

    void batch(String tableName, long bufferSize, List<? extends Mutation> mutations);
}
